package com.luoran.bartalks.utils;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;

import com.luoran.bartalks.entity.biz.BtRuleRecord;

/**
 * 打尺记录取列名
 * 
 * @author WMM 2018年10月23日上午10:25:21
 * @version 1.0
 */
public enum EnumRuleRecordColumnName {

	POSITION(0, "位置"), LENGTH(1, "打尺长度(cm)"), WIDTH(2, "打尺宽度(cm)"), HEIGHT(3, "打尺高度(cm)"), VOLUME(4,
			"预估体积(cm³)"), EMPTYWEIGHT(5,
					"净重"), PERSON(6, "打尺人员"), RULEDATE(7, "打尺时间"), ISEXCEPTION(8, "是否异常"), DESCRIPTION(9, "描述/备注");
	private final Integer value;
	private final String name;

	EnumRuleRecordColumnName(Integer value, String name) {
		this.value = value;
		this.name = name;
	}

	public Integer getValue() {
		return this.value;
	}

	public String getName() {
		return this.name;
	}

	public static String getColumnName(Integer value) {
		String name = "";
		switch (value) {
		case 0:
			name = POSITION.getName();
			break;
		case 1:
			name = LENGTH.getName();
			break;
		case 2:
			name = WIDTH.getName();
			break;
		case 3:
			name = HEIGHT.getName();
			break;
		case 4:
			name = VOLUME.getName();
			break;
		case 5:
			name = EMPTYWEIGHT.getName();
			break;
		case 6:
			name = PERSON.getName();
			break;
		case 7:
			name = RULEDATE.getName();
			break;
		case 8:
			name = ISEXCEPTION.getName();
			break;
		case 9:
			name = DESCRIPTION.getName();
			break;
		default:
			name = "未知";
			break;
		}
		return name;
	}

	public static String getMethod(Integer value, BtRuleRecord data) {
		String text = "";
		switch (value) {
		case 0:
			text = data.getPositionName();
			break;
		case 1:
			text = data.getLength().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 2:
			text = data.getWidth().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 3:
			text = data.getHeight().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 4:
			text = data.getLength().multiply(data.getWidth())
					.multiply(data.getHeight().setScale(6, BigDecimal.ROUND_HALF_UP)).toPlainString();
			break;
		case 5:
			text = data.getWeight().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 6:
			text = data.getOperator();
			break;
		case 7:
			text =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(data.getRuleDate());
			break;
		case 8:
			text = data.getIsException().equals("1")  ? "是" : "否";
			break;
		case 9:
			text = data.getDescription();
			break;
		default:
			text = "";
			break;
		}
		if (text == null) {
			text = "";
		}
		return text;
	}

}
